package org.aplikator.client.shared.rpc;

import org.aplikator.client.shared.data.*;
import org.aplikator.client.shared.descriptor.ApplicationDTO;
import org.aplikator.client.shared.descriptor.FunctionDTO;
import org.aplikator.client.shared.descriptor.RecordsPageDTO;
import org.aplikator.client.shared.descriptor.SuggestionsDTO;
import org.aplikator.client.shared.descriptor.WidgetDTO;
import org.aplikator.client.shared.descriptor.ViewDTO;

import javax.ws.rs.*;

import java.util.List;

import org.aplikator.client.shared.descriptor.WizardPageDTO;
import org.aplikator.client.shared.descriptor.ProcessDTO;

/**
 * The client side stub for the RPC service.
 */
@Path("aplikatorService")
public interface AplikatorService  {

    @GET
    @Path("/getApplication")
    @Produces("application/json")
    public ApplicationDTO getApplication();

    @GET
    @Path("/getView/{id}")
    @Produces("application/json")
    public ViewDTO getView(@PathParam("id") String id);


    @POST
    @Path("/getSuggestions")
    @Consumes("application/json")
    @Produces("application/json")
    public SuggestionsDTO getSuggestions(String viewid,  @QueryParam("req") String req);

    @POST
    @Path("/getRecord")
    @Consumes("application/json")
    @Produces("application/json")
    public Record getRecord(@QueryParam("primaryKey") String primaryKey, String viewId);

    @POST
    @Path("/getCompleteRecord")
    @Consumes("application/json")
    @Produces("application/json")
    public Record getCompleteRecord(@QueryParam("primaryKey") String primaryKey, @QueryParam("traverseLevel") int traverseLevel,@QueryParam("includecollections") boolean includeCollections);
    
    @POST
    @Path("/getPage")
    @Consumes("application/json")
    @Produces("application/json")
    public RecordsPageDTO getPage(ParameterWrapperGetPage parameterWrapperGetPage, @QueryParam("ownerPrimaryKey") String primaryKey, @QueryParam("pageOffset") int pageOffset, @QueryParam("pageSize") int pageSize);

    @POST
    @Path("/getPageSearch")
    @Consumes("application/json")
    @Produces("application/json")
    public SearchResult getPageSearch(String viewId, @QueryParam("searchArgument") String searchArgument, @QueryParam("pageOffset") int pageOffset, @QueryParam("pageSize") int pageSize);

    
    @POST
    @Path("/getRecordCount")
    @Consumes("application/json")
    @Produces("text/plain")
    public int getRecordCount(ParameterWrapperGetPage parameterWrapperGetPage, @QueryParam("ownerPrimaryKey") String ownerPrimaryKey, @QueryParam("search") boolean search);

    @POST
    @Path("/runFunction")
    @Consumes("application/json")
    @Produces("text/plain")
    public String runFunction(ParameterWrapperRunFunction parameterWrapperRunFunction);

    @GET
    @Path("/getFunction/{id}")
    @Produces("application/json")
    public FunctionDTO getFunction(@PathParam("id") String id);

    @PUT
    @Path("/getFunction/{funcid}/nextWizardPage")
    @Consumes("application/json")
    @Produces("application/json")
    public WizardPageDTO getWizardPage(@PathParam("funcid") String funcId, @QueryParam("previouspage")String prevPage, @QueryParam("forward") boolean forwardFlag, ParameterWrapperRunFunction parameterWrapperRunFunction);
    
    @POST
    @Path("/prepareRecord")
    @Consumes("application/json")
    @Produces("application/json")
    public Record prepareRecord(@QueryParam("primaryKey") String primaryKey, String viewId);

    @POST
    @Path("/processRecords")
    @Consumes("application/json")
    @Produces("application/json")
    public RecordContainer processRecords(RecordContainer rc);

    
    // processes part
    @GET
    @Path("/processes")
    @Produces("application/json")
    public List<ProcessDTO> getProcesses();
    

    @GET
    @Path("/processes/{procid}")
    @Produces("application/json")
    public ProcessDTO getProcess(@PathParam("procid") String procId);

    @PUT
    @Path("/processes/{procid}")
    @Produces("application/json")
    public ProcessDTO stopProcess(@PathParam("procid") String procId, @QueryParam("stop") String stop);

    @DELETE
    @Path("/processes/{procid}")
    @Produces("application/json")
    public ProcessDTO deleteProcess(@PathParam("procid") String procId);

    
}


/*public ApplicationDTO getApplication();

    public ViewDTO getView( String id);

    public RecordContainer processRecords(RecordContainer rc);

    public SuggestOracle.Response getSuggestions(ViewDTO view,  SuggestOracle.Request req);

    public Record getRecord(ViewDTO view,  PrimaryKey primaryKey);

    public List<Record> getPage(ViewDTO view, PropertyDTO ownerProperty,  PrimaryKey ownerPrimaryKey, int pageOffset,  int pageSize);

    public int getRecordCount(ViewDTO view,  PropertyDTO ownerProperty, PrimaryKey ownerPrimaryKey, boolean search);

    public String runFunction(FunctionDTO function,  ClientContext clientContext,  Record functionParameters);

    public FunctionDTO getFunction( String id);
*/